package blazingbubble.config;

import org.apache.log4j.Logger;

import java.net.InetAddress;
import java.util.HashMap;

import blazingbubble.config.exception.ConfigValidationException;

public class Config {
	private static Logger logger = Logger.getLogger(Config.class);

	private static String RESOURCE_PATH;

	private InetAddress serverAddress;
	private Integer serverUdpPort;
	private Integer frameBreak;
	private HashMap<String, MultiplayerFieldInformation> multiplayerFieldInformation = new HashMap<String, MultiplayerFieldInformation>();

	public InetAddress getServerAddress() {
		return serverAddress;
	}

	public void setServerAddress(InetAddress serverAddress) {
		this.serverAddress = serverAddress;
	}

	public Integer getServerUdpPort() {
		return serverUdpPort;
	}

	public void setServerUdpPort(Integer serverUdpPort) {
		this.serverUdpPort = serverUdpPort;
	}

	public void setFrameBreak(Integer frameBreak) {
		this.frameBreak = frameBreak;
	}

	public Integer getFrameBreak() {
		return frameBreak;
	}

	public void validate() throws ConfigValidationException {
		if(serverAddress == null) {
			throw new ConfigValidationException("Server address not specified");
		}
		if(serverUdpPort == null) {
			throw new ConfigValidationException("Server udp port not specified");
		}
		if(frameBreak == null) {
			throw new ConfigValidationException("Framebreak not specified");
		}
	}

	public HashMap<String, MultiplayerFieldInformation> getMultiplayerFieldInformation() {
		return multiplayerFieldInformation;
	}

	public static String getResourcePath() {
		return RESOURCE_PATH;
	}

	public static String getSpriteMapsPath() {
		return RESOURCE_PATH +  "/graphics/spriteMaps";
	}

	public static String getTexturesPath() {
		return RESOURCE_PATH +  "/graphics/textures";
	}

	public static String getLevelsPath() {
		return RESOURCE_PATH +  "/graphics/levels";
	}

	public static String getMultiplayerFieldConfig() {
		return Config.getLevelsPath() + "/mplayer.ini";
	}

	public static void setResourcePath(String RESOURCE_PATH) {
		Config.RESOURCE_PATH = RESOURCE_PATH;
	}
}